#ifndef LEXER_HH_
# define LEXER_HH_

# include "stl.h"

# include "interface/chat/Token.hh"

// more or less dummy lexer
// cd need a LL(1) parser
// if result depends on what we'll get after current str
// or a nextToken function

/** builds annd returns token list to the parser
 **
 ** both Client && Server side
 */
class Lexer
{
public:
  Lexer(std::string input);
  ~Lexer();

  std::vector<e_token> buildTokenList();

private:
  /** returns the first token matching \param str
   ** for each char found, add it to the current string
   ** and call matchingToken with building string
   */
  e_token matchToken(std::string str);

  /** returns the first one char length token matching \param c
   ** \return TOK_UNKNOWN if c does not match any token
   */
  e_token matchOneCharToken(char c);


  /** returns \param c if it's a separator char
   ** it browses CHAT_SEPARATOR_STRING
   */
  char isSeparator(char c);


  std::string _input; // user's input, from current point to the end
  unsigned int _len; /// user's input total length

  /** number of separators in CHAT_SEPARATOR_STRING
   ** basicaly, _nbSeparator == strlen (CHAT_SEPARATOR_STRING)
   */
  unsigned int _nbSeparator;

  std::vector<e_token> _tokenList; // NOTE watch this
};

#endif /* !LEXER_HH_ */
